package cn.exrick.common.utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
import java.util.UUID;

public class IDUtil {

    public static String getRandomId() {
        return UUID.randomUUID().toString().replace("-","");
    }

    public static String getOrderNo(){
        Date date = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
        StringBuilder orderNo = new StringBuilder(dateFormat.format(date));
        Random random = new Random();
        for (int i = 0; i < 6; i++) {
            orderNo.append(random.nextInt(10));
        }

        return orderNo.toString();
    }

    public static String getOrderCode(){
        StringBuilder code = new StringBuilder();
        Random random = new Random();
        for (int i = 0; i < 6; i++) {
            code.append(random.nextInt(10));
        }

        return code.toString();
    }

}

